import axios from 'axios'
export default {
  namespaced: true,
  state: {
    newList: {}
  },
  mutations: {
    updateNewList (state, { currentCategory, list }) {
      state.newList = { ...state.newList, [currentCategory]: list }
    }
  },
  actions: {
    async getNewList ({ commit }, currentCategory) {
      const { data: { data: { results } } } = await axios({ url: `http://192.168.11.34:8000/v1_0/articles?channel_id=${currentCategory}&timestamp=${Date.now()}&with_top=1` })
      commit('updateNewList', { currentCategory, list: results })
    }
  }
}
